package com.kalle.workflow.query;

import com.kalle.workflow.elements.Process;
import com.kalle.workflow.enums.ProcessStatus;
import com.kalle.workflow.mapper.ProcessMapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ProcessQuery extends AbstractQuery<Process> {

    private final ProcessMapper processMapper;

    private final Map<String, Object> conditionMap;

    public ProcessQuery(ProcessMapper processMapper) {
        this.processMapper = processMapper;
        this.conditionMap = new HashMap<>();
    }

    public ProcessQuery id(String id) {
        conditionMap.put("id", id);
        return this;
    }

    public ProcessQuery processKey(String processKey) {
        conditionMap.put("processKey", processKey);
        return this;
    }

    public ProcessQuery active() {
        conditionMap.put("processStatus", ProcessStatus.ACTIVE.name());
        return this;
    }

    @Override
    List<Process> list() {
        return processMapper.list(conditionMap);
    }

}
